#include <unittest++/UnitTest++.h>
#include <Ape/Collections/LinkedList.h>

namespace ApeTest {
	namespace Collections {
		using Ape::Collections::LinkedList;
		
		/*
		 * Here we add some elements into the list and
		 * then fetch them and assert that they are still in the same order
		 */
		TEST (Ape_Collections_LinkedList__BasicTest) {
			LinkedList<int> intList;
			intList << 1 << 2 << 3 << 4;
			
			int topCnt = intList.get_Count();
			
			int i1, i2, i3, i4;
			i1 = intList.FetchFirst();
			i2 = intList.FetchFirst();
			i3 = intList.FetchFirst();
			i4 = intList.FetchFirst();
			
			int lowCnt = intList.get_Count();
			
			CHECK_EQUAL (1, i1);
			CHECK_EQUAL (2, i2);
			CHECK_EQUAL (3, i3);
			CHECK_EQUAL (4, i4);
			CHECK_EQUAL (4, topCnt);
			CHECK_EQUAL (0, lowCnt);
		}
		
		TEST (Ape_Collections_LinkedList__IteratorTest) {
			LinkedList<int> intList;
			intList << 1 << 2 << 3 << 4;
			
			/*
			 * it will be increased prior to each loop iteration:
			 * so it should be equal to the Item under the cursor
			 */
			int currentNumber = 0;
			foreach (it, LinkedList<int>, intList) {
				currentNumber++;
				int i = (int) it;
				CHECK_EQUAL (currentNumber, i);
			}
		}
	}
}









